package com.lanchuan.soft.controller;

import com.lanchuan.soft.entity.ParamUser;
import com.lanchuan.soft.service.IUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("user")
@Log4j2
public class UserController {

    private IUserService userService;

    @Autowired
    public UserController(IUserService userService) {
        this.userService = userService;
    }

    // 登陆
    @RequestMapping("login")
    public Map<String, Object> login(@RequestBody ParamUser paramUser) {
        return userService.login(paramUser);
    }

    // 登陆
    @RequestMapping("login2")
    public Map<String, Object> login2(ParamUser paramUser) {
        return userService.login(paramUser);
    }

    // 添加用户
    @RequestMapping("createUser")
    public Map<String, Object> createUser(@RequestBody ParamUser paramUser) {
        return userService.createUser(paramUser);
    }

    // 更新用户
    @RequestMapping("updateUser")
    public Map<String, Object> updateUser(ParamUser paramUser) {
        return userService.updateUser(paramUser);
    }

    // 更新用户
    @RequestMapping("updateUser2")
    public Map<String, Object> updateUser2(@RequestBody ParamUser paramUser) {
        return userService.updateUser(paramUser);
    }

    // 全部用户列表
    @RequestMapping("findUserList")
    public Map<String, Object> findUserList() {
        return userService.findUserList();
    }

    // 当前用户所在组织中队员列表
    @RequestMapping("findMemberList")
    public Map<String, Object> findMemberList(@RequestBody ParamUser paramUser) {
        return userService.findMemberList(paramUser);
    }

    @RequestMapping("findMemberList2")
    public Map<String, Object> findMemberList2(ParamUser paramUser) {
        return userService.findMemberList(paramUser);
    }

    // 当前用户所在组织中队员列表
    @RequestMapping("findDepartmentList")
    public Map<String, Object> findDepartmentList(@RequestBody ParamUser paramUser) {
        return userService.findDepartmentList(paramUser);
    }
}
